package com.gzhxhx.czh.myhuibaomin.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.gzhxhx.czh.myhuibaomin.R;
import com.gzhxhx.czh.myhuibaomin.httpgetset.ShoyegrideUtils;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;
import java.util.List;

public class ShoyegrideAdapter extends BaseAdapter {
    Context context;
    List<ShoyegrideUtils.DataBean> list = new ArrayList<>();

    public ShoyegrideAdapter(Context context,List<ShoyegrideUtils.DataBean> list){
            this.context = context;
            this.list = list;
    }
    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        TeView teView;
        if (convertView==null){
            teView = new TeView();
            convertView = View.inflate(context, R.layout.itme_gride_shoye_list,null);
          teView.imgTx = convertView.findViewById(R.id.img_itme_grid_tp);
          teView.tvWenzhi = convertView.findViewById(R.id.tv_itme_grid_wz);
            convertView.setTag(teView);
        }else {
            teView = (TeView) convertView.getTag();
        }
        teView.tvWenzhi.setText(list.get(position).getWenzhi());
        Picasso.with(context)
                .load(list.get(position).getImgurl())
                .error(R.drawable.logo)
                .into( teView.imgTx);
        return convertView;
    }

    class TeView{
        ImageView imgTx;
        TextView tvWenzhi;
    }
}
